console.log('�� instrumentation.js 文件被加载')
let executionCount = 0
export async function register() {
    executionCount++

    console.log(`
        �� ===== INSTRUMENTATION REGISTER =====
        �� 执行时间: ${new Date().toLocaleString()}
        �� 执行次数: ${executionCount}
        �� 运行环境: ${process.env.NODE_ENV}
        �� 运行时: ${process.env.NEXT_RUNTIME}
        �� 工作目录: ${process.cwd()}
        ==========================================
          `)
    // 确保只在 Node.js 运行时执行
    if (process.env.NEXT_RUNTIME === 'nodejs') {
      console.log('�� Instrumentation: 正在初始化...')
      
      try {
        // 动态导入避免在边缘运行时出错
        const { initializeTasks } = await import('./src/lib/tasks/index')
        
        // 启动定时任务
        await initializeTasks()
        
        console.log('✅ Instrumentation: 定时任务启动完成')
      } catch (error) {
        console.error('❌ Instrumentation: 启动定时任务失败', error)
      }
    }
}